﻿<Window x:Class="EventMonitor.Windows.EventLogWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:sys="clr-namespace:System;assembly=mscorlib"
	xmlns:diag="clr-namespace:EventMonitor.EventLogs"
	xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid"
    Title="EventLogWindow" Height="300" Width="600">
	<Window.Resources>
		<ObjectDataProvider x:Key="EventLogSource" ObjectType="{x:Type diag:WindowsEventLog}" MethodName="GetEventLogs" />
		<ObjectDataProvider x:Key="EventLogItemSource" ObjectType="{x:Type diag:WindowsEventLog}" MethodName="GetEventLogEntries">
			<ObjectDataProvider.MethodParameters>
				<sys:String>Application</sys:String>
			</ObjectDataProvider.MethodParameters>
		</ObjectDataProvider>
		<Style x:Key="LabelStyle" TargetType="{x:Type TextBlock}">
			<Setter Property="VerticalAlignment" Value="Center"/>
			<Setter Property="Margin">
				<Setter.Value>
					<Thickness Right="20"/>
				</Setter.Value>
			</Setter>
		</Style>
	</Window.Resources>

	<DockPanel>
		<WrapPanel DockPanel.Dock="Top">
			<TextBlock Style="{StaticResource LabelStyle}">Select a log:</TextBlock>
			<ComboBox Name="EventLogName" ItemsSource="{Binding Source={StaticResource EventLogSource}}" SelectedIndex="0">
				<ComboBox.ItemTemplate>
					<DataTemplate>
						<Label Content="{Binding Path=Log}"/>
					</DataTemplate>
				</ComboBox.ItemTemplate>
				<ComboBox.Text>  
                    <Binding Source="{StaticResource EventLogItemSource}"    
                             Path="MethodParameters[0]"    
                             BindsDirectlyToSource="True"  
                             Mode="OneWayToSource">   
                    </Binding>  
                </ComboBox.Text> 
			</ComboBox>
			<Button Name="EventLogSelect" Click="EventLogSelect_Click">Select</Button>
		</WrapPanel>
		<xcdg:DataGridControl x:Name="EventsList" AutoCreateColumns="False"
			ItemsSource="{Binding Source={StaticResource EventLogItemSource}}">
			<xcdg:DataGridControl.Columns>
				<xcdg:Column Title="ID" FieldName="EventID" />
				<xcdg:Column Title="Category" FieldName="Category" />
				<xcdg:Column Title="Entry Type" FieldName="EntryType" />
				<xcdg:Column Title="Source" FieldName="Source" />
				<xcdg:Column Title="Message" FieldName="Message" />
			</xcdg:DataGridControl.Columns>
		</xcdg:DataGridControl>

		<!--<xcdg:DataGridControl x:Name="OrdersGrid"
                        ItemsSource="{Binding Source={StaticResource EventLog}}"/>-->

		<!--<igDP:XamDataPresenter x:Name="EventLogEntryItems">
			<igDP:XamDataPresenter.View>
				<igDP:GridView/>
			</igDP:XamDataPresenter.View>
			<igDP:XamDataPresenter.FieldLayoutSettings>
				<igDP:FieldLayoutSettings AutoGenerateFields="False" />
			</igDP:XamDataPresenter.FieldLayoutSettings>
			<igDP:XamDataPresenter.FieldLayouts>
				<igDP:FieldLayout>
					<igDP:FieldLayout.Fields>
						<igDP:Field Name="EventID" Label="ID">
							<igDP:Field.Settings>
								<igDP:FieldSettings CellWidth="50" />
							</igDP:Field.Settings>
						</igDP:Field>
						<igDP:Field Name="Category" Label="Category">
							<igDP:Field.Settings>
								<igDP:FieldSettings CellWidth="125" />
							</igDP:Field.Settings>
						</igDP:Field>
						<igDP:Field Name="EntryType" Label="Entry Type">
							<igDP:Field.Settings>
								<igDP:FieldSettings CellWidth="75" />
							</igDP:Field.Settings>
						</igDP:Field>
						<igDP:Field Name="Source" Label="Source">
							<igDP:Field.Settings>
								<igDP:FieldSettings CellWidth="50" />
							</igDP:Field.Settings>
						</igDP:Field>
						<igDP:Field Name="Message" Label="Message">
							<igDP:Field.Settings>
								<igDP:FieldSettings CellWidth="300" />
							</igDP:Field.Settings>
						</igDP:Field>
					</igDP:FieldLayout.Fields>
				</igDP:FieldLayout>
			</igDP:XamDataPresenter.FieldLayouts>
		</igDP:XamDataPresenter>-->
	</DockPanel>
</Window>
